Skip to content

Send every page iteration to the cloud, and keep responses made for one visitor out of the cache - #295

Merged
jwrosewell merged 7 commits into
rcfrom
feature/cloud-request-engine-browser-test-pass-through
Dec 1, 2026
Merged

jwrosewell merged 7 commits into
rcfrom
feature/cloud-request-engine-browser-test-pass-through

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

When a page loads the pipeline's JavaScript from the publisher's server, the browser runs the browser tests and posts the answers back to that server, which passes them on to the cloud through the Cloud Request Engine. This pull request makes sure that server route sends the cloud what it needs on every iteration of a page, and that a response made for one visitor is never stored in or served from the engine's response cache.

  1. The session id and the sequence the JavaScript was written with, and the browser test answers the page posted or stored as 51D_ cookies, reach the cloud unchanged on every iteration.
  2. A server that supplies the visitor's IP address, JA4 and H2 as query evidence (query.client-ip, query.ja4 and query.h2) has them sent to the cloud on every iteration, with the supplied address replacing the address the request arrived from.
  3. The response cache follows the rule below.

Points 1 and 2 already held on rc, and the new tests pin them down. Point 3 is the code change.

The response cache rule

This pull request follows the response cache rule set for the Cloud Request Engine in every language, exactly. A cloud response made for one visitor is never stored in or served from the response cache. That covers:

  1. any response carrying a sealed Human Confidence result. It is told from the HumanConfidence value itself, as text that is not blank and is none of High, Medium or Low, the only values HumanConfidence has, letter case ignored, and never from HumanConfidenceSource, because the route decides sealing and a sealed result can be Passive or Active.
  2. any response carrying the browser tests' script.
  3. any response carrying a 51Did.
  4. any request carrying a session id, a sequence, a JA4 or HTTP/2 settings.

How the engine meets each one, with member names compared in any case:

Rule Where What is checked
1 CloudRequestEngine.is_cacheable, humanconfidence.is_sealed_value derived.humanconfidence is text, not blank, and none of High, Medium or Low in any letter case, so Unknown counts as sealed
2 CloudRequestEngine.is_cacheable browserderived.browsertestsjavascript is not blank
3 CloudRequestEngine.is_cacheable a top-level member named fodid, as the caching page of the specification already says
4 CloudRequestEngine.process, CloudRequestEngine.bypasses_cache evidence named session-id, sequence, ja4 or h2 under any prefix (Constants.UNCACHED_EVIDENCE_NAMES)

is_cacheable is asked both before a response is stored and when an entry is found, so an entry that breaks the rule is not served even where it got into the cache some other way. A request for rule 4 never reaches the cache at all. rc already sent a request carrying a sealed result to redeem (query.humanconfidence) straight to the cloud, because a sealed result redeems once, and that stays.

The cache key is built from the evidence keys the cloud lists, but the engine sends every evidence value. The session id, the sequence and the browser test answers are not in that list, so without rule 4 two iterations of one page that differ only in those would share a key, and the iteration carrying the answers would be answered from the cache and never reach the cloud.

Merge with rc

The branch was 52 commits behind rc, and rc is merged in by 2aad47b5. Two files conflicted, each where rc and this branch changed the same lines.

  • cloudrequestengine.py, in CloudRequestEngine.process. rc already skips the cache for a request that carries a sealed Human Confidence result to redeem. The resolution skips the cache when either a sealed result is present or bypasses_cache is true. It keeps rc's form of calling process_internal without assigning its result, because process_internal returns nothing.
  • constants.py. rc's HIDDEN_VALUE and this branch's UNCACHED_EVIDENCE_NAMES were added in the same place, and both are kept.

Rules 1 and 2 are added by d7ff3857, and 8c5d4004 compares the values in any letter case. 8c5d400 also counted Unknown as a value rather than a sealed result, which a0502f0d undoes, because HumanConfidence has the values High, Medium and Low only. d7ff385 also corrects the comments on bypasses_cache and UNCACHED_EVIDENCE_NAMES. They said the cloud does not list the JA4 and H2, but the cloud's public evidence key list (https://cloud.51degrees.com/api/v4/evidencekeys, read on 1 December 2026) holds query.ja4, header.ja4, server.ja4, query.h2, header.h2 and server.h2, though not session-id or sequence. The comments now give the rule's reason, a request made for one visitor.

Tests

tests/test_server_route_pass_through.py follows the back and forth through a Flask application that serves the JavaScript and the JSON endpoint, as a web integration does, with a mock cloud client in place of the service. Flask is added to the package's tox.ini test dependencies, and pipeline/ci/setup-environment.ps1 already installs it in CI.

tests/test_cloudrequestengine_cache.py covers rules 1 to 3 through a pipeline with a cache. For rule 1 it checks a sealed result whose source is Passive (neither stored nor served), a sealed result whose source is Active, absent or anything else, an unsealed Active value (High, Medium and Low are cached), each of those in another letter case (cached), Unknown with no source or a Passive or Active one and in lower case (neither stored nor served), a null value with its null reason (cached), a blank value (cached), the names in any case, and a sealed-looking value under another data key (cached). For rule 2 it checks the script in any case (neither stored nor served) and a null or blank script (cached).

The cloud request engine package's tests were run on Windows with Python 3.12, with no resource key or licence key set and the live tests deselected (-m "not live"), at a0502f0.

  • 196 passed, 2 skipped (the live licence key tests, which need a key) and 4 deselected (live).
  • Taking out the rule 1 and rule 2 checks fails four of the new cache tests, and counting Unknown as a value fails test_unknown_is_neither_stored_nor_served.
  • Taking out the bypasses_cache condition in process fails test_every_iteration_reaches_the_cloud_through_a_cache and test_a_supplied_connection_is_never_served_from_a_cache. Taking out the sealed result condition fails test_a_request_with_a_sealed_result_skips_the_cache. So both sides of the resolved conflict are covered by a test.

CI runs are listed in the comments below.

test_available_properties fails with "Property: serviceworkers is not present in the results" on every Build and Test job of rc already, for example rc's release run at d79e0e62. That failure comes from the key CI uses, not from this change.

Jamesr51d and others added 5 commits November 26, 2026 12:50
…est answers and visitor connection to the cloud
Two files conflicted, each where rc and this branch changed the same
lines.

In cloudrequestengine.py, CloudRequestEngine.process, rc skips the cache
for a request that carries a sealed Human Confidence result, because a
sealed result redeems once. This branch skips the cache for a request
that bypasses_cache picks out, being one carrying a session id, a
sequence, a JA4 or an H2, because the cache key leaves those out. The
resolution skips the cache when either is true. As on rc, the call to
process_internal is not assigned, because process_internal returns
nothing and pylint flags the assignment.

In constants.py, rc added HIDDEN_VALUE and this branch added
UNCACHED_EVIDENCE_NAMES in the same place. Both are kept.

The cloud request engine's tests pass with no keys set (185 passed, 2
skipped live licence key tests, 4 live tests deselected). Taking out
either condition fails a test, being
test_a_request_with_a_sealed_result_skips_the_cache for the sealed
result, and test_every_iteration_reaches_the_cloud_through_a_cache and
test_a_supplied_connection_is_never_served_from_a_cache for
bypasses_cache.
A cloud response made for one visitor is never stored in or served from
the response cache. The branch already kept out a response holding a
51Did (a top-level fodid) and a request carrying a session id, a
sequence, a JA4 or an H2, and rc kept out a request carrying a sealed
result to redeem. is_cacheable now also keeps out:

- a response carrying a sealed Human Confidence result, being a
  derived.humanconfidence whose value is text that is not blank and is
  none of High, Medium or Low. HumanConfidenceSource is never read,
  because the route decides sealing and a sealed result can be Passive
  or Active.
- a response carrying the browser tests' script, being a
  browserderived.browsertestsjavascript that is not blank.

Member names are compared in any case, as fodid already was.

The comments on bypasses_cache and UNCACHED_EVIDENCE_NAMES now give the
reason the rule gives, a request made for one visitor, and no longer say
the cloud service does not list the JA4 and H2, which its evidence key
list now does.

New tests in test_cloudrequestengine_cache.py cover a sealed Passive
result, a sealed result with any source, an unsealed Active value
(High, Medium and Low are cached), a null value, a blank value, the
names in any case, the browser tests' script and a null or blank script.
The cloud request engine's tests pass with no keys set (194 passed, 2
skipped live licence key tests, 4 live tests deselected), and taking out
either new check fails four of the new tests.
@jwrosewell jwrosewell changed the title Send every page iteration and supplied connection to the cloud when a cache is set Send every page iteration to the cloud, and keep responses made for one visitor out of the cache Dec 1, 2026
HumanConfidence is published with the values High, Medium, Low and
Unknown, so a sealed result is text that is not blank and is none of
those four, letter case ignored. is_sealed_value treated Unknown as
sealed and compared the other three in their exact case, so a response
whose HumanConfidence was Unknown, or a published value in another case,
was kept out of the response cache.

UNSEALED_VALUES now holds the four published values in lower case and
is_sealed_value compares the value in lower case. The cache tests cache
Unknown with an Active source, Unknown with no source or a Passive one,
and each published value in another letter case. The cloud request
engine's tests pass with no keys set (195 passed, 2 skipped live
licence key tests, 4 live tests deselected), and taking Unknown out of
UNSEALED_VALUES fails two of the cache tests.
HumanConfidence has the values High, Medium and Low only, so Unknown is
text other than those and counts as a sealed result, which the response
cache never stores or serves. This undoes the Unknown part of 8c5d400.
The letter case of a value is still ignored, as the rule says.

UNSEALED_VALUES is back to high, medium and low. The cache tests no
longer cache Unknown, and a new test checks that Unknown, with no source
or a Passive or Active one and in lower case, is neither stored nor
served. High, Medium and Low in another letter case are still cached.

The cloud request engine's tests pass with no keys set (196 passed, 2
skipped live licence key tests, 4 live tests deselected), and putting
Unknown back in UNSEALED_VALUES fails the new test.
@jwrosewell

Copy link
Copy Markdown
Contributor Author

CI so far.

Pull Requests workflow, started as a dry run on rc so it builds this pull request without merging it: run 46604408961. It built 8c5d400, the head before a0502f0. Configure chose Ubuntu with Python 3.10 and 3.14.

Job Result
Build and Test, Ubuntu_Python_3.10 Every test passed except test_available_properties
Build and Test, Ubuntu_Python_3.14 Every test passed except test_available_properties

test_available_properties fails on both with "Property: serviceworkers is not present in the results", the same failure every Build and Test job of rc has, for example rc's release run at d79e0e62. It comes from the key CI uses, not from this change. In both jobs the cloud request engine package ran 201 tests, all passing.

The checks this pull request runs passed at 8c5d400, including Cloud Human Confidence Tests against the staging cloud.

A second dry run for a0502f0 is listed in the next comment.

@jwrosewell
jwrosewell merged commit 5234367 into rc Dec 1, 2026
6 checks passed
@jwrosewell
jwrosewell deleted the feature/cloud-request-engine-browser-test-pass-through branch December 1, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants